package ch11.d8;

import java.util.Scanner;

public class Test8 {
    public static void main(String[] args) throws InterruptedException {


        Scanner scan=new Scanner(System.in);
        MyThread t1=null;
        while(true){
            System.out.println("请输入一个整数：");
            int n=scan.nextInt();
            if(n==1){
                System.out.println("开启线程");
                t1 = new MyThread();
                t1.start();
            }else if(n==2){
                t1.stop();
            }else if(n==3) {
                t1.interrupt();
            }else{
                synchronized (MyThread.list){
                    System.out.println("list.size()="+MyThread.list.size());
                }


            }

        }





    }
}
